<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="test"></div>
    <script src="../lib/react.development.js"></script>
    <script src="../lib//react-dom.development.js"></script>
    <script src="../lib/babel.min.js"></script>
    <script type="text/babel"> 
    class MyComponent extends React.Component{
        myRef=React.createRef()
        myRef2=React.createRef()
        //一个createref只能存储一个节点,如果存储多个会被最后一个覆盖(需要在重新创建一个容器)
        demo=()=>{
            console.log(this)
         console.log(this.myRef.current.value)
        }
        change=()=>{
            console.log(this.myRef2.current.value)
        }
        render(){
            return (
                <div>
                    <input type="text" ref={this.myRef} placeholder="请输入内容" onBlur={this.demo}/>
                <h3 >我是createref</h3>
                <input type="text" ref={this.myRef2} placeholder="请输入内容" onBlur={this.change}/>
                </div>
            )
        }
    }
    ReactDOM.render(<MyComponent/>,document.getElementById('test'))
    </script>  
</body>
</html>